<template>
	<div class="all">
		
	</div>
</template>

<script>
	import axios from 'axios'
	export default {
		name: 'login',
		data() {
			return {
				code:""
			}
		},
		created() {
			this.code = this.getUrlParam("code")
			this.login()
		},
		methods: {
			//获取url的code用
			getUrlParam:function(name) {   
			    var query = window.location.search.substring(1);
			    var vars = query.split("&");
			    for (var i=0;i<vars.length;i++) {
			            var pair = vars[i].split("=");
			            if(pair[0] == name){return pair[1];}
			    }
			    return(false);
			}, 
			//登陆
			login: function() {
				//测试登录
				// this.axios.post(this.urls+`/web/user/login?username=admin&password=123456`)
				// 	.then(response => {
				// 		if (response.data.success == true) {
				// 			this.person = response.data.result.userInfo
				// 			this.$router.push('/')
				// 		} else {
				// 			this.$message.error(response.data.message);
				// 		}
				// 	})
				
				//微信登录
				this.axios.post(this.urls+`/auth/open_login`,{"token":this.code,"appid":"wx154dd8349a505277","scope":"userinfo"})
					.then(response =>  {
						if(response.data.msg.code == 0){
							this.$router.push('/')
						}else{
						    this.$message.error(response.data.msg.info);
						}
					})
					
			}
		},

	}
</script>

<style scoped lang="less">
	.all {
		display: flex;
		height: 100vh;
		align-items: center;
		justify-content: center;

		.logo {
			text-align: center;
			margin-bottom: 20px;
		}

		.title {
			font-size: 25px;
			text-align: center;
			margin-bottom: 50px;
			font-weight: bold;
			background-image: linear-gradient(135deg, red, blue);
			-webkit-background-clip: text;
			color: transparent;
		}
	}
</style>
